﻿//-----------------------------------------------------------------------
// <copyright file="ServiceBase.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings

using System;
using GateShift.Services.SDK.Services.Hosts;
using GateShift.Services.SDK.Services.Interfaces;

#endregion

namespace GateShift.Services.SDK.Services
{
    /// <summary>
    /// Base class for all game services
    /// </summary>
    public abstract class ServiceBase : IService
    {
        /// <summary>
        /// Event fired when the service has finished initializing
        /// </summary>
        public event EventHandler Initialized;

        /// <summary>
        /// Gets or sets the reference to the ServerHost for integration
        /// </summary>
        public IServerHost ServerHost { protected get; set; }

        /// <summary>
        /// Method to initilaize the service. 
        /// </summary>
        public virtual void Initialize()
        {
            OnInitialized();
        }

        /// <summary>
        /// Event raiser for when a service finishes initializing
        /// </summary>
        protected void OnInitialized()
        {
            if (Initialized != null)
            {
                Initialized(this, EventArgs.Empty);
            }
        }
    }
}
